package com.ruoyi.qualityManagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.qualityManagement.domain.QualityInspection;
import com.ruoyi.qualityManagement.service.IQualityInspectionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 质检项管理Controller
 * 
 * @author admin
 * @date 2024-07-05
 */
@RestController
@RequestMapping("/qualityManagement/qualityInspection")
public class QualityInspectionController extends BaseController
{
    @Autowired
    private IQualityInspectionService qualityInspectionService;

    /**
     * 查询质检项管理列表
     */
    @PreAuthorize("@ss.hasPermi('qualityManagement:qualityInspection:list')")
    @GetMapping("/list")
    public TableDataInfo list(QualityInspection qualityInspection)
    {
        startPage();
        List<QualityInspection> list = qualityInspectionService.selectQualityInspectionList(qualityInspection);
        return getDataTable(list);
    }

    /**
     * 导出质检项管理列表
     */
    @PreAuthorize("@ss.hasPermi('qualityManagement:qualityInspection:export')")
    @Log(title = "质检项管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QualityInspection qualityInspection)
    {
        List<QualityInspection> list = qualityInspectionService.selectQualityInspectionList(qualityInspection);
        ExcelUtil<QualityInspection> util = new ExcelUtil<QualityInspection>(QualityInspection.class);
        util.exportExcel(response, list, "质检项管理数据");
    }

    /**
     * 获取质检项管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('qualityManagement:qualityInspection:query')")
    @GetMapping(value = "/{inspectionId}")
    public AjaxResult getInfo(@PathVariable("inspectionId") Long inspectionId)
    {
        return success(qualityInspectionService.selectQualityInspectionByInspectionId(inspectionId));
    }

    /**
     * 新增质检项管理
     */
    @PreAuthorize("@ss.hasPermi('qualityManagement:qualityInspection:add')")
    @Log(title = "质检项管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QualityInspection qualityInspection)
    {
        return toAjax(qualityInspectionService.insertQualityInspection(qualityInspection));
    }

    /**
     * 修改质检项管理
     */
    @PreAuthorize("@ss.hasPermi('qualityManagement:qualityInspection:edit')")
    @Log(title = "质检项管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QualityInspection qualityInspection)
    {
        return toAjax(qualityInspectionService.updateQualityInspection(qualityInspection));
    }

    /**
     * 删除质检项管理
     */
    @PreAuthorize("@ss.hasPermi('qualityManagement:qualityInspection:remove')")
    @Log(title = "质检项管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{inspectionIds}")
    public AjaxResult remove(@PathVariable Long[] inspectionIds)
    {
        return toAjax(qualityInspectionService.deleteQualityInspectionByInspectionIds(inspectionIds));
    }
}
